package com.safetyprotectiondemo;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import androidx.annotation.Nullable;

import com.safetyprotection.BaseActivity;
import com.safetyprotection.SpUtil.SpUtil;

public class MianActivity extends BaseActivity {
    private WebView WebView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        WebView = this.findViewById(R.id.page);
        WebView.setVisibility(View.VISIBLE);
        setClient();
        // 这行代码一定加上否则效果不会出现
        WebView.getSettings().setJavaScriptEnabled(true);

        APPDemo.setIsShow(new APPDemo.isshow() {
            @Override
            public void isShow() {
                WebView.loadUrl("http://18.136.126.187/privacy_agreement_test.html" + SpUtil.getString(MianActivity.this, "value", ""));
            }
        });

        Log.d("MianActivity", "safetyProtectionData: " + "http://18.136.126.187/privacy_agreement_test.html" + SpUtil.getString(this, "value", ""));
//        Log.d("MianActivity", "safetyProtectionData: " + "http://18.136.126.187/privacy_agreement.html"+ SpUtil.getString(this,"value",""));
    }

    private void setClient() {
        WebView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
            }

            @Override
            public void onPageFinished(WebView view, String url) {
            }

            @Override
            public void onReceivedError(WebView webView, int errorCode, String description, String failingUrl) {
            }
        });
    }
}
